//  @ Project : GagalPanen
//  @ File Name : fruitconstants.cpp
//  @ Date : 3/9/2011
//  @ Author : Irvan
//
//


#include "fruitconstants.hpp"
#include "plants.hpp"
#include "view.hpp"
#include "creatures.hpp"
#include "disaster.hpp"
#include "gametime.hpp"

#include <assert.h>

const int FruitConstants::kFruitCount = 12;

const std::string FruitConstants::kFruitsNames[] =
{
  "Algorithm and Data Structure",
  "User Interface",
  "Internet Programming",
  "Object Oriented Programming",
  "Banana",
  "Computer Organization",
  "Rila Mandala",
  "5 Friends",
  "IP 4",
  "Laptop",
  "100 Fruit",
  "1000 Fruit"
};

const std::string FruitConstants::kFruitsDescriptions[] =
{
  "Your grade is D",
  "Your grade is E",
  "Your grade is B",
  "Your grade is C",
  "A yellow and healthy fruit that Karol likes very much",
  "You receive 0 score!",
  "Ketua Kelas ganteng",
  "Memakan buah ini, Anda harus menyebarkan program ini kelima teman Anda. Jika tidak, siap-siap menerima kutukan.",
  "IP bisa menjadi 4 dengan makan buah ini.",
  "Laptop dari lap?",
  "Buah ini berharga 100",
  "Buah ini berharga 1000"
};

const std::string FruitConstants::kFruitsEatenDescriptions[] =
{
  "All stroke death! All plants died\n",
  "Give one turn of ITBPC anti-disaster protection\n",
  "Give you 5 extra actions this turn\n",
  "Nothing happened\n",
  "One of your plants becomes a banana seed\n",
  "Ir. Sukarno was born at 6 June 1901\n",
  "Tanaman anda jadi clausal form",
  "Silakan lakukan sesuai deskripsi buah tersebut",
  "IP Anda sekarang menjadi 4...mungkin",
  "Kasian laptop mahal sampai dimakan...",
  "Anda merasa 100x lebih baik...mungkin",
  "Anda merasa 1000x lebih baik...mungkin",
};

const int FruitConstants::kFruitsSellPrices[] =
{
  200,
  400,
  520,
  400,
  150,
  500,
  300,
  -500,
  750,
  950,
  100,
  1000
};

int FruitConstants::getFruitCount() {
  return kFruitCount;
}

std::string FruitConstants::getFruitName(int fruit_id) {
  assert(fruit_id >= 0 && fruit_id < FruitConstants::getFruitCount());
  return kFruitsNames[fruit_id];
}

int FruitConstants::getFruitSellPrice(int fruit_id) {
  assert(fruit_id >= 0 && fruit_id < FruitConstants::getFruitCount());
  return kFruitsSellPrices[fruit_id];
}

std::string FruitConstants::getFruitDescription(int fruit_id) {
  return kFruitsDescriptions[fruit_id];
}

void FruitConstants::eatFruit(GameInterface* game, int fruit_id) {
  assert(fruit_id >= 0 && fruit_id < getFruitCount());
  game->getView()->showString(kFruitsEatenDescriptions[fruit_id]);
  switch (fruit_id) {
    case 0:
      // alstruk
      game->getCreatures()->getPlants()->makeAllDead();
      break;
    case 1 :
      // UI
      game->getDisaster()->addProtection(1);
      break;
    case 2 :
      // internet prog
      game->getGameTime()->decreaseTime(5);
      break;
    case 3 :
      // OOP
      // nothing happened
      break;
    case 4 :
      // banana
      // transmutation into banana plant
      game->getCreatures()->getPlants()->transmutateOneRandomPlant(4);
      break;
    case 5 :
      // orkom
      // sampah efeknya
      break;
  }
}

